package com.aaa.depression.controller;

import com.aaa.depression.service.DepressionTestPlanService;
import com.aaa.pojo.Page;
import com.aaa.pojo.Plan;
import com.aaa.pojo.ResultBean;
import com.aaa.pojo.question_fpa;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

@Controller
@RequestMapping("/accounttestsds")
@ResponseBody
public class DepressionTestPlanController {
    @Autowired
    private DepressionTestPlanService depressionTestPlanService;
    @RequestMapping("/findAlltestsds")
    public ResultBean findAll(Page page, Plan plan){
        return depressionTestPlanService.findAlltest(page,plan);
    }

    @RequestMapping("/delete")
    public int delete(Integer id){
        int delete = depressionTestPlanService.delete(id);

        return delete;
    }
    @RequestMapping("/deletes")
    public int deletes(@RequestParam Integer[] id){
        return depressionTestPlanService.deletes(id);
    }

    @RequestMapping("/save")
    public int save(Plan plan){
        plan.setCreate_time(new Date());
        plan.setTest_code((int) ((Math.random() * 9 + 1) * 100000));
        return depressionTestPlanService.save(plan);
    }

    @RequestMapping("/update")
    public int update(Plan plan){
        return depressionTestPlanService.update(plan);
    }
}
